completion: shutdown: suggest 'now' for time argument#162
Open
nickshiro wants to merge 1 commit intozsh-users:masterfrom
Open
completion: shutdown: suggest 'now' for time argument#162nickshiro wants to merge 1 commit intozsh-users:masterfrom
nickshiro wants to merge 1 commit intozsh-users:masterfrom
Conversation
skewb1k
reviewed
Mar 9, 2026
skewb1k
left a comment
There was a problem hiding this comment.
Isn't the same behavior achievable with a simpler change like this?
diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown
index a237b14e0..a31990a4a 100644
--- a/Completion/Unix/Command/_shutdown
+++ b/Completion/Unix/Command/_shutdown
@@ -11,7 +11,7 @@ if [[ -d /etc/systemd ]]; then
"(--no-wall)-k[don't shutdown, just write wall message]" \
"(-k)--no-wall[don't send a wall message]" \
'-c[cancel pending shutdown]' \
- '1: :_guard "^-*" "time (now/hh\:mm/+mins)"' \
+ '1: :{ _guard "^-*" "time (now/hh:mm/+mins)" && compadd now }' \
'*:warning message'
return
fi
@@ -23,7 +23,7 @@ case $OSTYPE in
'-r[reboot the system]'
'-k[kick everybody off]'
'-n[prevent file system cache from being flushed]'
- '1: :_guard "^-*" "time (now/hh\:mm/+mins)"'
+ '1: :{ _guard "^-*" "time (now/hh:mm/+mins)" && compadd now }' \
'*:warning message'
)
;|This preserves _guard behavior while also adding completion for 'now'.
While I haven't found similar uses of compadd inline in _arguments, that's probably because it's a relatively rare case where an argument takes on both known and arbitrary values.
Author
|
@skewb1k, that's a nice simplification. I wasn't sure whether inline If maintainers are fine with this approach I'm switch to it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current shutdown completion uses
_guardfor the time argument:_guardonly validates the argument but does not provide completioncandidates. As a result, usage such as:
does not complete to
shutdown now.This patch introduces a completion state for the time argument and
adds a suggestion for the commonly used value
now. The completionstill allows arbitrary values such as
+minsandhh:mm.